package top.zhangjianyong.blog.enums;

import java.util.List;
import lombok.Getter;

/**
 * 角色关键字枚举
 *
 * @author zhangjianyong
 * @since 2024/7/29 下午8:54
 */
@Getter
public enum RoleKeys {
  ADMIN("admin"),
  WRITER("writer"),
  READER("reader"),
  ;
  private final String key;

  RoleKeys(String key) {
    this.key = key;
  }

  public boolean hasRole(List<String> roles) {
    return roles.stream().anyMatch(this.key::equals);
  }
}
